<template>
	<div>
		<!--网络 选择-->
		<baseSelect 
			:autoSelect="autoSelect"
			ref="baseSelect"
			:defaultValue="defaultValue" 
			:optionList="options" 
			@change="changeHandel"></baseSelect>
	</div>
</template>

<script>
	import baseSelect from "@/view/components/select/select";
	import {getEthoInfo} from "@/service/swagger/DashboardController"
	
	export default {
		components : {
			baseSelect
		},
		props:[
			"defaultValue",
			"ip",
			"autoSelect",
		],
		data(){
			return {
				options: [],
			}
		},
		mounted(){
			this.getData();
		},
		methods : {
			changeHandel(name , v){
				this.$emit("change", "wangluoSelect", v)
			},
			
			getData(ip){ 
				if(!ip){
					return ;
				}
				getEthoInfo({
					ip : ip || this.ip || "",
				}).then(ret=>{
					if(ret&&ret.data){
						this.options = ret.data.map(el=>{
							return {
								label : el ,
								value : el ,
							}
						})
					}
					if(!this.options[0]||this.options[0].value!=""){
						this.options.unshift({
							label : "全部" ,
							value : "" ,
						})
					}
					this.$refs.baseSelect.asyncUpdateOption(this.options)
				})
			},
			
			reset(){
				this.$refs.baseSelect.reset();
			}
		}
	}
</script>

<style>
</style>